package api

import (
	"client/global"
	"encoding/json"
	"github.com/gin-gonic/gin"
	"server/proto"
)

func EsCount(c *gin.Context) {
	index := c.PostForm("index")
	title := c.PostForm("title")
	res, err := global.RpcClient.EsCount(c, &proto.EsCountReq{
		Index: index,
		Title: title,
	})
	if err != nil {
		c.JSON(200, gin.H{
			"code": -1,
			"msg":  err.Error(),
		})
		return
	}
	var rr []string
	json.Unmarshal(res.Data, &rr)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "success",
		"data": rr,
	})
	return
}
